package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"runtime"
	"strings"
	"time"
)

func main() {
	urls := []string{"http://wx.itopfood.com/mobile/test.php", "http://uapi.hfjy.com", "http://uapi-test.hfjy.com", "http://test.net/test.php", "http://shop.hfjy.com"}
	runtime.GOMAXPROCS(1)
	fmt.Println(runtime.NumCPU())
	tag := make(chan string, 10)
	start := time.Now()
	for _, url := range urls {
		go func(url string, tag chan<- string) {
			start := time.Now()
			resp, _ := http.Get(url)

			defer resp.Body.Close()
			_, _ = ioutil.ReadAll(resp.Body)
			//fmt.Println(string(body))
			fmt.Println(time.Since(start).Seconds())
			tag <- url + "->" + "ok"
		}(url, tag)
	}
	for range urls {
		re := <-tag
		tt := strings.Split(re, "->")[0]
		fmt.Println(tt)
	}
	fmt.Println(time.Since(start).Seconds())
	fmt.Println("ok")

}
